package com.stars.controller.mygenerate;
/**
 * Created by luodajie on 2019/1/8.
 */

import com.stars.common.base.ResultMsg;
import com.stars.controller.advice.CommonExceptionHandler;
import com.stars.services.mygenerate.MyGenerateService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author :dj
 * @version : 1.0.0
 * @description
 * @Date 2019-01-08 18:12
 * @note
 */
@Slf4j
@RestController
@RequestMapping("/auto")
@Api(tags="项目代码生成主类")
public class AutoGenerateCtl extends CommonExceptionHandler {

    @Autowired
    private MyGenerateService myGenerateService;
    /**
     * 生成代码
     *
     * @param ids 数据库表的id,来源cgFormHead 表
     * @return
     */
    @PostMapping(value = "/generate")
    @ApiOperation(value = "生成代码入口",notes = "数据库表的ids,来源cgFormHead 表")
    public ResultMsg generate(String ids) throws Exception {
        return myGenerateService.autoCodeBtl(ids);
    }

    /**
     *
     * @param ids
     * @return
     */
    @PostMapping(value = "/generateDb")
    @ApiOperation(value = "同步数据库表",notes = "数据库表的ids,来源cgFormHead 表")
    public ResultMsg generateDb(String ids)throws Exception{
        return myGenerateService.autoDbGenerate(ids);
    }


}
